<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
    export default {
        mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.Edit],
        components: {
            SelectImage: async () => Vue.extend(await Vue.prototype.$vFN.Components.Base.SelectImage())
        },
        data() {
            return {
                appWindow: window,
                form: {
                    dealer: 2,
                    level_id: "",
                },
                
                loading: true,
                levelList: [],
            };
        },
        methods: {
            async getLvele() {
                let res = await this.$vFN.Http.post({
                    url: "plugin/team-dividend/admin/level/list",
                }, window);
                res.data.list.forEach(item => {
                    if(item.id != this.id) {
                        this.levelList.push(item);
                    }
                });
            },
            
            async delLvele() {
                let res = await this.$vFN.Http.post({
                    url: "plugin/team-dividend/admin/level/destroyLevel",
                    data: {
                        ids: [this.id],
                        dealer: this.form.dealer == 1 ? "move" : "delete",
                        level_id: this.form.dealer == 2 ? this.id : this.form.level_id,
                    }
                }, window);
                if(res.code == 200) {
                    this.mixinEdit_editVisible = false;
                    this.onSuccess();
                    this.$vFN.Tools.messageSuccess("操作成功");
                }
            },

            // 初始化
            async init() {
                this.mixinEdit_editVisible = true
                this.getLvele()
            },

            // 成功回调
            onSuccess() {},
            // 取消回调
            onCancel() {},
            // 失败回调
            onError() {},


        },
        mounted() {
            this.init();
        },
        activated() {},
    };
</script>